package projectchumashgeniusproject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import projectchumashgeniusproject.ProjectChumashGeniusProject.BookName;

public class Verse implements Serializable
{
    private int verseNum, chapterNum;
    private BookName book;
    private List<Phrase> phrases;
    
    public Verse(int vn, int cn, BookName bn)
    {
        this(vn, cn, bn, new ArrayList<Phrase>());
    }
    public Verse(int vn, int cn, BookName bn, ArrayList<Phrase> p)
    {
        this.verseNum = vn;
        this.chapterNum = cn;
        this.book = bn;
        this.phrases = new ArrayList<>(p);
    }
    public int getVerseNumber()
    {
        int vn = verseNum;
        return vn;
    }
    public int getChapterNumber()
    {
        int cn = chapterNum;
        return cn;
    }
    public BookName getBook()
    {
        BookName bn = book;
        return bn;
    }
    public List<Phrase> getPhrases()
    {
        return new ArrayList<>(phrases);
    }
    public void addPhrase(Phrase p)
    {
        phrases.add(p.getPhraseNumber() - 1, p);
    }
    @Override
    public int hashCode()
    {
        int hash = 3;
        hash = 67 * hash + this.verseNum;
        hash = 67 * hash + this.chapterNum;
        hash = 67 * hash + Objects.hashCode(this.book);
        hash = 67 * hash + Objects.hashCode(this.phrases);
        return hash;
    }
    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        
        final Verse other = (Verse) obj;
        
        if (this.verseNum != other.verseNum)
            return false;
        if (this.chapterNum != other.chapterNum)
            return false;
        if (this.book != other.book)
            return false;
        if (!Objects.equals(this.phrases, other.phrases))
            return false;
        
        return true;
    }
    public boolean isEquivlant(Object obj)
    {
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        
        final Verse other = (Verse) obj;
        
        if (!Objects.equals(this.phrases, other.phrases))
            return false;
        
        return true;
    }
}